package carte;

import graphes.Arc;
import graphes.Noeud;

public abstract class Voie extends Arc {
	protected String nom;
	protected double distance;
	protected double vitesseMoyenne;
	
	public static final double coutEssence=1.5;
	public static final int TYPETEMPS = 1;
	public static final int TYPEDISTANCE = 2;
	public static final int TYPEPRIX = 3;
	public static int typeRecherche = TYPETEMPS;

	public Voie() {

	}

	public Voie(Noeud deb, Noeud fin) {
		super(deb, fin);
	}

	@Override
	public double getPoids() {
		switch (typeRecherche) {
		case TYPETEMPS:
			return getByTemps();
		case TYPEDISTANCE:
			return getDistance();
		case TYPEPRIX:
			return getByPrix();
		default:
			return getByTemps();
		}
	}

	public double getByTemps() {
		return distance/vitesseMoyenne;
	}

	public double getByDistance() {
		return distance;

	}

	public double getByPrix() {
		if (vitesseMoyenne>=100){
			return coutEssence*7*distance/100;
		}
		return coutEssence*6*distance/100;
	}

	public String getNom() {
		return nom;
	}

	public void setNom(String nom) {
		this.nom = nom;
	}

	public double getDistance() {
		return distance;
	}

	public void setDistance(double distance) {
		this.distance = distance;
	}

	public double getVitesseMoyenne() {
		return vitesseMoyenne;
	}

	public void setVitesseMoyenne(double vitessemoyenne) {
		this.vitesseMoyenne = vitessemoyenne;
	}
	
	public String toString(){
		return "-"+getNom()+" de "+getDebut() + " à "+getFin();
	}

}
